package com.zerui.manager.app.accessrecord.executer;

import com.alibaba.cola.catchlog.CatchAndLog;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zerui.manager.accessrecord.AccessRecord;
import com.zerui.manager.accessrecord.domainservice.AccessRecordRepository;
import com.zerui.manager.app.accessrecord.convertor.AccessRecordVoConvert;
import com.zerui.manager.web.cmd.AccessRecordQryCmd;
import com.zerui.manager.web.vo.AccessRecordVO;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author wh
 * @create_time 2023-08-31 17:42
 */
@Component
@CatchAndLog
public class AccessRecordQryCmdExe {

    @Resource
    private AccessRecordRepository accessRecordRepository;

    public Page<AccessRecordVO> executePage(AccessRecordQryCmd accessRecordQryCmd) {
        Page<AccessRecord> recordPage =  accessRecordRepository.getPageList(accessRecordQryCmd);
        return AccessRecordVoConvert.INSTANCE.covertAccessRecordToPageVO(recordPage);
    }

    public void execute(AccessRecordQryCmd accessRecordQryCmd, HttpServletResponse response) {
        accessRecordRepository.getAccessRecordListExport(accessRecordQryCmd,response);
    }
}
